package edu.gdkm.dao;

import edu.gdkm.pojo.Product;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ProductMapper {
    @Select("select * from tb_product where id in (select product_id from " +
            "tb_ordersitem where orders_id = #{id} )")
    List<Product> selectProductByOrdersId(int orders_id);
    @Select("select * from tb_product where id =#{id}")
    @Results({
            @Result(id = true,column = "id", property = "id"),
            @Result(column = "id",
                    property = "ordersList",
                    many = @Many(select = "edu.gdkm.dao.OrdersMapper.selectOrdersByProductId"))
    })
    Product selectProductById(int product_id);
}
